Package Info
Package Info offers access to Cargo manifest information from within your Rust code.
Actually, Cargo offers that by exposing it via environment variables.
However, if you are running your application from binary (as opposed to via cargo run
),
those environment variables are no longer present.
Package Info works around this issue by capturing the environment variable values during
compile and embedding them in your code via the derived trait PackageInfo
. You must add both
package_info
and package_info_derive
as dependencies to your project.
Usage
use PackageInfo; // the trait
use PackageInfo; // the derive macro
The PackageInfo
trait provides the following functions, all of which return a Option<String>
:
/// Accessor functions to common Cargo package information as specified in Cargo.toml